import request from "@/utils/request"
import { useUserInfoStore } from '@/stores/userInfo'

// 普通聊天调用
export const _aiChat = (msg, chatId) => {
  return request.get('/api/chat/v1', {
    params: { msg, chatId }
  })
}

// 流式聊天调用
export const _aiChatStream = (msg, chatId) => {
  const userInfoStore = useUserInfoStore()
  const token = userInfoStore.userInfo?.token || ''
  
  return fetch(`/api/chat/v2?msg=${encodeURIComponent(msg)}&chatId=${chatId}`, {
    method: 'GET',
    headers: {
      'Authorization': token ? `Bearer ${token}` : ''
    }
  })
}
